package com.pb.web.action;

import com.opensymphony.xwork2.ActionSupport;
import com.pb.entity.User;

public class UserAction extends ActionSupport {

	private static final long serialVersionUID = -1783819998312712862L;

	private User user;
	
	@Override
	public String execute() throws Exception {
		//验证用户名
		if (null==user.getUsername()||"".equals(user.getUsername())) {
			this.addFieldError("user.username", "用户名不能为空（业务方法）");
		}
		//验证密码
		if (null==user.getPassword()||"".equals(user.getPassword())) {
			this.addFieldError("user.password", "密码不能为空（业务方法）");
		}
		//完成注册业务
		//addActionError("用户名或密码错误");//添加Action错误
		if (this.hasErrors()) {
			return INPUT;
		}
		return SUCCESS;
	}

	/**
	 * 获取 user
	 * @return user 
	 */
	public User getUser() {
		return user;
	}

	/**
	 * 设置 user 
	 * @param user user
	 */
	public void setUser(User user) {
		this.user = user;
	}
	
	
}
